/*
 * @Author: 杨权
 * @Date: 2022-03-31 13:48:59
 * @LastEditors: Junjun
 * @LastEditTime: 2022-04-27 16:18:18
 * @Description: file content
 */
import Vue from 'vue';
export default {}.install = (Vue, options = {}) => {
  Vue.directive('loadmore', {
    inserted(el, binding) {
      // 获取element-ui定义好的scroll盒子
      let SELECTDOWN_DOM = el.querySelector('.el-select-dropdown .el-select-dropdown__wrap');
      // 修饰符 当前元素为滚动的盒子
      if (binding.modifiers.current) {
        SELECTDOWN_DOM = el;
      }
      SELECTDOWN_DOM.addEventListener('scroll', function () {
        const CONDITION = Math.floor(this.scrollHeight - this.scrollTop) <= this.clientHeight;
        // console.log(this.scrollHeight - this.scrollTop);
        if (CONDITION) {
          binding.value();
        }
      });
    },
  });
};
